<?php
  class Class_A2Xml extends Core_Base {
    private $root;
    function __construct($root = 'root')
    {
      $this->root = $root;
    }
    function toXml($arr, $node = null) {
      if($node === null) {
          $simxml = new simpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><' . $this->root . '></' . $this->root . '>');
      } else {
          $simxml = $node;
      }
      foreach($arr as $k => $v) {
          if(is_array($v)) {
            $this->toXml($v, $simxml->addChild($k));
          } else {
            $simxml->addChild($k,$v);
          }
      }
      return $simxml->saveXML();
    }
  }